/*
 * 
 * Created on Jul 11, 2005
 */
package com.wgo.bpot.common.transport.exception;

/**
 * 
 * 
 * @author Petter L. H. Eide
 * @version $Id: RematoException.java,v 1.1 2006-01-23 09:27:22 petterei Exp $
 * 
 * Changelog:
 * 
 * $Log: RematoException.java,v $
 * Revision 1.1  2006-01-23 09:27:22  petterei
 * initial commit of alternative session implementation
 *
 * Revision 1.6  2005-12-16 18:08:00  petterei
 * *** empty log message ***
 *
 * Revision 1.5  2005-12-05 04:03:52  petterei
 * *** empty log message ***
 *
 * Revision 1.4  2005/10/02 21:37:20  petterei
 * *** empty log message ***
 *
 * Revision 1.3  2005/07/20 06:15:15  peide3
 * more exceptions from server to user
 *
 * Revision 1.2  2005/07/14 06:34:34  peide3
 * Cleand up, restructured, implemented more functionality
 *
 *
 */
public class RematoException extends RuntimeException {
	private static final long serialVersionUID = 2L;
	public RematoException() {
		super();
	}
	public RematoException(String message) {
		super(message);
	}
	public RematoException(String message, StackTraceElement[] stackTrace) {
		super(message);
		setStackTrace(stackTrace);
	}
	
	public RematoException(String message, Throwable cause) {
		super(message + " " + cause.getClass().getSimpleName() + ": " + cause.getMessage());
		internalInitCause(cause);
	}
	
	public RematoException(Throwable cause) {
		super(cause.getClass().getSimpleName() + ": " + cause.getMessage());
		internalInitCause(cause);
	}
	
	/**
	 * To get original stacktrace for exception possibly unknown to the client 
	 * without overwrite this stacktrace
	 */
	private void internalInitCause(Throwable cause) {
		if (null != cause) {
//			RematoException initCause = new RematoException(cause.getMessage());
//			initCause.setStackTrace(cause.getStackTrace());
//			initCause(initCause);
			initCause(cause);
			setStackTrace(cause.getStackTrace());
		}
	}
}
